package controladores;

import modelo.datos.areaprofesional;
import modelo.hibernate.dao.DaoArea_Profesional;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Button;
import org.zkoss.zul.Textbox;

public class controladorRegistrararea extends SelectorComposer<Component>{

	private static final long serialVersionUID = 1L;
	private DaoArea_Profesional dao = new DaoArea_Profesional();
	private areaprofesional area= new areaprofesional();
	
	@Wire
	private Textbox codigo;
	@Wire
	private Textbox nombre;
	@Wire
	private Button btnRegistrar;
	@Wire
	private Button btnCancelar;
	
	 @Listen("onClick=#btnRegistrar")
		public void onClick$btnRegistrar(MouseEvent event){
		                   
		                 area.setCodarea(codigo.getValue());
		                 area.setNomarea(nombre.getValue());
													
						try {	
								dao.agregarAreaProfesional(area);
								
							
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();	
						}
						LimpiarCampos();
			}
		
	 @Listen("onClick=#btnCancelar")
	   	public void onClick$btnCancelar(MouseEvent event){
	    	Executions.sendRedirect("principal.zul");
	    }
	    
	    public void LimpiarCampos()
	    {
	    	codigo.setText("");
	    	nombre.setText("");
	    }

	
	
	
	
	
	
}
